//////////////////////////////////////////////////////////////////////////
#pragma once


#include <Rocket/Core.h>
#include <Math/Point2i.hpp>
#include <SFML/Window.hpp>
#include <lua.hpp>


namespace UI
{
	class Context
	{
	public:
		//
		typedef Rocket::Core::Element				RocketElement;
		typedef Rocket::Core::ElementDocument		RocketDocument;

		//
		Context();
		Context( const std::string& name, const Math::Point2i& size );
		~Context();

		//
		bool						Initialize( const std::string& name, const Math::Point2i& size, Rocket::Core::RenderInterface* ri );

		//
		bool						OverUI();
		bool						ProcessInput( const sf::Event& );
		void						Update();
		void						Render();
		void						ClearCache();
		RocketElement*				GetHoverElement();
		RocketDocument*				LoadDocument( const std::string& name );
		void						UnloadAllDocuments();
		void						SetDimensions( uint32_t x, uint32_t y );

		void						Reload( lua_State* );

		void						InitDebugger() const;
//		Rocket::Core::Context*		TheContext() const;

	private:
		//
		typedef Rocket::Core::Input::KeyIdentifier	RocketKey_t;

		//
		static int					_GetKeyModifiers();
		static RocketKey_t			_TranslateKey( sf::Keyboard::Key Key );

		//
		std::string					mName;
		Math::Point2i				mSize;
		Rocket::Core::Context*		mpContext;
		bool						mMouseMoved;
		Math::Point2i				mLastMousePos;
	};
}
